package com.pkk.cloud.support.gataway.spring.config.custom;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @description: 自定义的路径线路解析
 * @author: peikunkun
 * @create: 2019-08-23 16:49
 **/
@Slf4j
public class CustomRequestPathKeyResolver implements KeyResolver {

  /**
   * bean的名称
   */
  public static final String KEY_RESOLVER_REQUEST_URL = "customRequestPathKeyResolver";


  /**
   * @Description: 把根据路径方式进行解析
   * @Param: [exchange]
   * @return: reactor.core.publisher.Mono<java.lang.String>
   * @Author: peikunkun
   * @Date: 2019/8/23 0023 下午 4:52
   */
  @Override
  public Mono<String> resolve(ServerWebExchange exchange) {
    log.info(this.getClass().getSimpleName() + "resolve  is init");
    return Mono.just(exchange.getRequest().getPath().value());
  }


}
